package com.pvdnc.systemdebugger.testclient;

import android.annotation.SuppressLint;
import android.content.Context;
import android.hardware.camera2.CameraManager;
import android.location.LocationManager;
import android.util.Log;

import com.pvdnc.systemdebugger.compacter.utils.AppContext;

import java.lang.reflect.Method;

public class TCompacter {
    private static final String TAG="TCompacter";

    public static void compacterClassExist(){
        try {
            Class<?> MyClass=ClassLoader.getSystemClassLoader().loadClass("com.pvdnc.systemdebugger.compacter.MyClass");
            Log.d(TAG,"MyClass:"+MyClass.getName());
            //说明SystemServer的特有类是在createSystemContext方法后加载的(@see SystemServer.run())
            @SuppressLint("PrivateApi") Class<?> SystemServiceManager=Class.forName("com.android.server.SystemServiceManager");
            Log.d(TAG,"SSM:"+SystemServiceManager.getName());
            Class<?> disexistClass=ClassLoader.getSystemClassLoader().loadClass("for.showDexPathList.inStackTrace");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void remoteAuth() {
        CameraManager mCM = (CameraManager) AppContext.getAppContext().getSystemService(Context.CAMERA_SERVICE);
        Log.d(TAG, "mCM is null ? " + String.valueOf(mCM == null));
        LocationManager mLM= (LocationManager) AppContext.getAppContext().getSystemService(Context.LOCATION_SERVICE);
        Log.d(TAG, "mLM is null ? " + String.valueOf(mLM == null));
    }

    public static void remotePolicy(){
        try {
            Class<?> SystemProperties=Class.forName("android.os.SystemProperties");
            Method get=SystemProperties.getDeclaredMethod("get", String.class, String.class);
            get.setAccessible(true);
            Log.d(TAG,"ro.serialno:"+get.invoke(null,"com.test.serial","unknown"));
            Log.d(TAG,"ro.serialno:"+get.invoke(null,"com.test.serial","unknown"));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
